//
//  PChartsController.swift
//  CJPack
//
//  Created by 陈警卫 on 2023-05-05.
//

import UIKit

class PChartsController: CJBaseBackController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        let chartsView = CJChartsView(frame: CGRect(x: 20, y: 100, width: view.cj_width - 40, height: view.cj_width - 40))
        view.addSubview(chartsView)

        let axis = CJChartsAxisConfig()
        //axis.xAxisCountForCell = 6
        axis.xPointInterval = 10.0
        
        axis.yAxisMaxValue = 10
        axis.yAxisMinValue = -10
        
        axis.yAxisAutoRange = true
        axis.yAxisMaxRangeValue = 90
        axis.yAxisMinRangeValue = -90
        
        axis.yAxisColor = .clear
        axis.yAxisCount = 6;

        axis.yAxisDashColor = .cj_color("929292", alpha: 0.4)
        
        axis.xAxisStyle = .time
        chartsView.axisConfig = axis
        
        let line1 = CJChartsLineConfig()
        line1.style = .step
        line1.lineColor = .cj_color("D22007")
        //line1.fillColors = [.cj_color("D22007"), .cj_color("D22295")]
        //line1.fillColors = [.clear]
        
        chartsView.lineConfigs = [line1]
        chartsView.setupConfig()
        
        Timer.scheduledTimer(withTimeInterval: 0.1, repeats: true) { timer in
            let randomValue = Double.random(in: -60...60)
            chartsView.setupValue(points: [randomValue])
        }
        /**
         */
        
        /**
         var datas = [[Double]]()
         var lines = [Double]()
         for _ in 0...1000 {
         let randomValue = Double.random(in: (1)...(10))
         lines.append(randomValue)
         }
         datas.append(lines)
         chartsView.setupValue(datas: datas)
         
         */
    }

}
